VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MsComCtl.ocx"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "ITGControls.ocx"
Begin VB.Form frmEnhanceCanvass 
   BackColor       =   &H00F7D9C2&
   BorderStyle     =   0  'None
   Caption         =   "Form1"
   ClientHeight    =   6555
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   11700
   FillStyle       =   0  'Solid
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   6555
   ScaleWidth      =   11700
   ShowInTaskbar   =   0   'False
   Begin MSComctlLib.StatusBar sbRS 
      Align           =   2  'Align Bottom
      Height          =   285
      Left            =   0
      TabIndex        =   0
      Top             =   6270
      Width           =   11700
      _ExtentX        =   20638
      _ExtentY        =   503
      _Version        =   393216
      BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
         NumPanels       =   5
         BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
         BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
         EndProperty
         BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Alignment       =   1
            AutoSize        =   1
            Bevel           =   0
            Object.Width           =   7410
            MinWidth        =   2
         EndProperty
         BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
         BeginProperty Panel5 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin ITGControls.ITGTab SSTab1 
      Height          =   3210
      Left            =   0
      TabIndex        =   14
      Top             =   -45
      Width           =   11565
      _ExtentX        =   20399
      _ExtentY        =   5662
      TabCount        =   2
      TabCaption(0)   =   "               Main               "
      TabContCtrlCnt(0)=   1
      Tab(0)ContCtrlCap(1)=   "ComunionFrames1"
      TabCaption(1)   =   "               List               "
      TabContCtrlCnt(1)=   1
      Tab(1)ContCtrlCap(1)=   "dtgList"
      TabTheme        =   2
      ActiveTabBackStartColor=   16250865
      ActiveTabBackEndColor=   16243138
      InActiveTabBackStartColor=   16243138
      InActiveTabBackEndColor=   16243138
      InActiveTabForeColor=   0
      BeginProperty ActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty InActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      OuterBorderColor=   4210752
      TopLeftInnerBorderColor=   4210752
      BottomRightInnerBorderColor=   4210752
      DisabledTabBackColor=   16243138
      DisabledTabForeColor=   -2147483630
      Begin MSDataGridLib.DataGrid dtgList 
         Height          =   2895
         Left            =   -75000
         TabIndex        =   28
         Top             =   315
         Width           =   11565
         _ExtentX        =   20399
         _ExtentY        =   5106
         _Version        =   393216
         AllowUpdate     =   0   'False
         AllowArrows     =   -1  'True
         Appearance      =   0
         HeadLines       =   1
         RowHeight       =   15
         TabAction       =   2
         FormatLocked    =   -1  'True
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   6
         BeginProperty Column00 
            DataField       =   "cTranNo"
            Caption         =   "Canvass No."
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   "dDate"
            Caption         =   "Date"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "MM/dd/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   3
            EndProperty
         EndProperty
         BeginProperty Column02 
            DataField       =   "cType"
            Caption         =   "Type"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   "MM/dd/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column03 
            DataField       =   "cPRNo"
            Caption         =   "Reference PR No."
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   "MM/dd/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column04 
            DataField       =   "cItemNo"
            Caption         =   "Product"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "MM/dd/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   3
            EndProperty
         EndProperty
         BeginProperty Column05 
            DataField       =   "cDesc"
            Caption         =   "Description"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            AllowRowSizing  =   0   'False
            BeginProperty Column00 
               ColumnAllowSizing=   -1  'True
               Locked          =   -1  'True
               ColumnWidth     =   1649.764
            EndProperty
            BeginProperty Column01 
               Locked          =   -1  'True
               ColumnWidth     =   1454.74
            EndProperty
            BeginProperty Column02 
               Locked          =   -1  'True
               ColumnWidth     =   1200.189
            EndProperty
            BeginProperty Column03 
               Locked          =   -1  'True
               ColumnWidth     =   1679.811
            EndProperty
            BeginProperty Column04 
               Locked          =   -1  'True
            EndProperty
            BeginProperty Column05 
               ColumnWidth     =   3270.047
            EndProperty
         EndProperty
      End
      Begin ITGControls.ComunionFrames ComunionFrames1 
         Height          =   2895
         Left            =   0
         Top             =   315
         Width           =   11565
         _ExtentX        =   20399
         _ExtentY        =   5106
         FrameColor      =   4210752
         BackColor       =   16243138
         FillColor       =   16243138
         RoundedCorner   =   0   'False
         Caption         =   "Canvass Information"
         Alignment       =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ThemeColor      =   5
         ColorFrom       =   16243138
         ColorTo         =   16250865
         Begin VB.Timer Timer1 
            Interval        =   300
            Left            =   3015
            Top             =   660
         End
         Begin VB.CommandButton cmdPickPRNo 
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Left            =   2595
            Picture         =   "frmEnhanceCanvass.frx":0000
            Style           =   1  'Graphical
            TabIndex        =   5
            Top             =   1005
            Width           =   315
         End
         Begin VB.ComboBox cboType 
            Appearance      =   0  'Flat
            BackColor       =   &H00FFFFFF&
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   315
            ItemData        =   "frmEnhanceCanvass.frx":014A
            Left            =   5925
            List            =   "frmEnhanceCanvass.frx":0157
            Style           =   2  'Dropdown List
            TabIndex        =   3
            Top             =   690
            Width           =   1215
         End
         Begin VB.CommandButton cmdPickItemNo 
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Left            =   2595
            Picture         =   "frmEnhanceCanvass.frx":0171
            Style           =   1  'Graphical
            TabIndex        =   7
            Top             =   1320
            Width           =   315
         End
         Begin VB.Frame Frame2 
            Appearance      =   0  'Flat
            BackColor       =   &H00F7D9C2&
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H80000008&
            Height          =   1065
            Left            =   7560
            TabIndex        =   17
            Top             =   525
            Width           =   3555
            Begin ITGControls.ITGTextBox txtBankRate 
               Height          =   285
               Left            =   120
               TabIndex        =   8
               Top             =   240
               Width           =   3270
               _ExtentX        =   5556
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Text            =   "0"
               DataType        =   1
               DecimalPlace    =   2
               Label           =   "Bank Rate per Annum (%)"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   2100
               TextBoxWidth    =   1110
            End
            Begin ITGControls.ITGTextBox txtLowestCODPrice 
               Height          =   285
               Left            =   120
               TabIndex        =   9
               Top             =   600
               Width           =   3270
               _ExtentX        =   5556
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Text            =   "0"
               DataType        =   1
               DecimalPlace    =   2
               Label           =   "Lowest Price @ COD"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   2100
               TextBoxWidth    =   1110
            End
         End
         Begin VB.Frame Frame3 
            Appearance      =   0  'Flat
            BackColor       =   &H00F7D9C2&
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H80000008&
            Height          =   1065
            Left            =   7575
            TabIndex        =   16
            Top             =   1575
            Width           =   3555
            Begin VB.CheckBox chkNewSupplier 
               BackColor       =   &H00F7D9C2&
               BeginProperty Font 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   240
               Left            =   180
               TabIndex        =   10
               TabStop         =   0   'False
               Top             =   285
               Width           =   240
            End
            Begin VB.CheckBox chkSupplier 
               BackColor       =   &H00F7D9C2&
               BeginProperty Font 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   240
               Left            =   180
               TabIndex        =   12
               TabStop         =   0   'False
               Top             =   630
               Width           =   240
            End
            Begin ITGControls.ITGTextBox txtNewSupplier 
               Height          =   285
               Left            =   480
               TabIndex        =   11
               Top             =   240
               Width           =   1515
               _ExtentX        =   2461
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Text            =   "0"
               DataType        =   1
               Label           =   "Must have"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1000
               TextBoxWidth    =   455
            End
            Begin ITGControls.ITGTextBox txtSupplier 
               Height          =   285
               Left            =   480
               TabIndex        =   13
               Top             =   600
               Width           =   1515
               _ExtentX        =   2461
               _ExtentY        =   503
               SendKeysTab     =   -1  'True
               LabelBackColor  =   16243138
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Text            =   "0"
               DataType        =   1
               Label           =   "Minimum of"
               BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               LabelWidth      =   1000
               TextBoxWidth    =   455
            End
            Begin VB.Label Label3 
               AutoSize        =   -1  'True
               BackStyle       =   0  'Transparent
               Caption         =   "Supplier/s"
               Height          =   195
               Left            =   2055
               TabIndex        =   27
               Top             =   645
               Width           =   705
            End
            Begin VB.Label Label2 
               AutoSize        =   -1  'True
               BackStyle       =   0  'Transparent
               Caption         =   "new Supplier/s"
               Height          =   195
               Left            =   2070
               TabIndex        =   26
               Top             =   285
               Width           =   1050
            End
         End
         Begin ITGControls.ITGTextBox txtTranNo 
            Height          =   285
            Left            =   135
            TabIndex        =   1
            Top             =   690
            Width           =   2430
            _ExtentX        =   4075
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "Canvass No."
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1120
            Required        =   -1  'True
         End
         Begin ITGControls.ITGDateBox dtbDate 
            Height          =   285
            Left            =   4035
            TabIndex        =   2
            Tag             =   "Transaction Date"
            Top             =   690
            Width           =   1305
            _ExtentX        =   2302
            _ExtentY        =   503
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   ""
            SendKeysTab     =   -1  'True
            Mandatory       =   -1  'True
         End
         Begin ITGControls.ITGTextBox txtDesc 
            Height          =   285
            Left            =   2925
            TabIndex        =   18
            TabStop         =   0   'False
            Top             =   1320
            Width           =   4230
            _ExtentX        =   7355
            _ExtentY        =   503
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "ITGtext"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   4170
            Enabled         =   0   'False
         End
         Begin ITGControls.ITGTextBox txtName 
            Height          =   285
            Left            =   2550
            TabIndex        =   19
            TabStop         =   0   'False
            Top             =   2265
            Width           =   4605
            _ExtentX        =   8017
            _ExtentY        =   503
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "ITGtext"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   4545
            Enabled         =   0   'False
         End
         Begin ITGControls.ITGTextBox txtLastPrice 
            Height          =   285
            Left            =   135
            TabIndex        =   20
            Top             =   1950
            Width           =   2415
            _ExtentX        =   4048
            _ExtentY        =   503
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "Last Price"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1105
            Enabled         =   0   'False
         End
         Begin ITGControls.ITGTextBox txtItemNo 
            Height          =   285
            Left            =   135
            TabIndex        =   6
            Top             =   1320
            Width           =   2430
            _ExtentX        =   4075
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "Product"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1120
            Required        =   -1  'True
            LinkForeColor   =   16711680
         End
         Begin ITGControls.ITGTextBox txtCode 
            Height          =   285
            Left            =   135
            TabIndex        =   21
            Top             =   2265
            Width           =   2415
            _ExtentX        =   4048
            _ExtentY        =   503
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Label           =   "Supplier"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1105
            Enabled         =   0   'False
         End
         Begin ITGControls.ITGTextBox txtPRNo 
            Height          =   285
            Left            =   135
            TabIndex        =   4
            Top             =   1005
            Width           =   2430
            _ExtentX        =   4075
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "Ref. PR No."
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1120
         End
         Begin ITGControls.ITGTextBox txtType 
            Height          =   285
            Left            =   5370
            TabIndex        =   22
            Tag             =   "cboType"
            Top             =   690
            Width           =   1680
            _ExtentX        =   2752
            _ExtentY        =   503
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Mandatory       =   -1  'True
            Label           =   "Type"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   800
            TextBoxWidth    =   820
            Required        =   -1  'True
         End
         Begin ITGControls.ITGTextBox txtTerm 
            Height          =   285
            Left            =   4275
            TabIndex        =   23
            Top             =   1950
            Width           =   2880
            _ExtentX        =   4868
            _ExtentY        =   503
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Label           =   "Last Term"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1570
            Enabled         =   0   'False
         End
         Begin ITGControls.ITGTextBox txtQty 
            Height          =   285
            Left            =   135
            TabIndex        =   24
            Top             =   1635
            Width           =   2415
            _ExtentX        =   4048
            _ExtentY        =   503
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "Qty. Needed"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1105
            Enabled         =   0   'False
         End
         Begin ITGControls.ITGTextBox txtBalance 
            Height          =   285
            Left            =   4275
            TabIndex        =   25
            Top             =   1635
            Width           =   2880
            _ExtentX        =   4868
            _ExtentY        =   503
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "Balance"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1570
            Enabled         =   0   'False
         End
         Begin VB.Label Label1 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "Date"
            Height          =   195
            Left            =   3585
            TabIndex        =   15
            Top             =   705
            Width           =   825
         End
      End
   End
   Begin ITGControls.ComunionFrames ComunionFrames2 
      Height          =   2520
      Left            =   0
      Top             =   3150
      Width           =   11565
      _ExtentX        =   20399
      _ExtentY        =   4445
      FrameColor      =   4210752
      BackColor       =   16243138
      FillColor       =   16243138
      RoundedCorner   =   0   'False
      Caption         =   "Details"
      Alignment       =   0
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ThemeColor      =   5
      ColorFrom       =   16243138
      ColorTo         =   16250865
      Begin VB.ComboBox cboTerm 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         ItemData        =   "frmEnhanceCanvass.frx":02BB
         Left            =   1455
         List            =   "frmEnhanceCanvass.frx":02BD
         Style           =   2  'Dropdown List
         TabIndex        =   30
         Top             =   2055
         Visible         =   0   'False
         Width           =   1035
      End
      Begin VB.ComboBox cboCanvass 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         ItemData        =   "frmEnhanceCanvass.frx":02BF
         Left            =   390
         List            =   "frmEnhanceCanvass.frx":02C9
         Style           =   2  'Dropdown List
         TabIndex        =   29
         Top             =   2025
         Visible         =   0   'False
         Width           =   1035
      End
      Begin MSDataGridLib.DataGrid dtgCanvass 
         Height          =   2100
         Left            =   0
         TabIndex        =   31
         Top             =   420
         Width           =   11565
         _ExtentX        =   20399
         _ExtentY        =   3704
         _Version        =   393216
         AllowUpdate     =   -1  'True
         AllowArrows     =   -1  'True
         BackColor       =   16777215
         HeadLines       =   1
         RowHeight       =   15
         TabAcrossSplits =   -1  'True
         TabAction       =   2
         FormatLocked    =   -1  'True
         AllowDelete     =   -1  'True
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   9
         BeginProperty Column00 
            DataField       =   "cSupType"
            Caption         =   "Type"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   "cCode"
            Caption         =   "Supplier"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   "0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column02 
            DataField       =   "cName"
            Caption         =   "Supplier Name"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column03 
            DataField       =   "cTerm"
            Caption         =   "Terms"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column04 
            DataField       =   "nPrice"
            Caption         =   "Price"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column05 
            DataField       =   "nSavings"
            Caption         =   "Savings"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column06 
            DataField       =   "cOtherFactors"
            Caption         =   "Other Factors"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column07 
            DataField       =   "cRating"
            Caption         =   "Rating"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column08 
            DataField       =   "lApproved"
            Caption         =   "[ A ]"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   5
               Format          =   """$""#,##0.00"
               HaveTrueFalseNull=   1
               TrueValue       =   "Y"
               FalseValue      =   "N"
               NullValue       =   "N"
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   7
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
               Button          =   -1  'True
               Locked          =   -1  'True
               ColumnWidth     =   1005.165
            EndProperty
            BeginProperty Column01 
               Button          =   -1  'True
               ColumnWidth     =   1049.953
            EndProperty
            BeginProperty Column02 
               Locked          =   -1  'True
               ColumnWidth     =   2250.142
            EndProperty
            BeginProperty Column03 
               Button          =   -1  'True
               Locked          =   -1  'True
               ColumnWidth     =   1110.047
            EndProperty
            BeginProperty Column04 
               Alignment       =   1
               ColumnWidth     =   1019.906
            EndProperty
            BeginProperty Column05 
               Alignment       =   1
               Locked          =   -1  'True
               ColumnWidth     =   1065.26
            EndProperty
            BeginProperty Column06 
               ColumnWidth     =   1200.189
            EndProperty
            BeginProperty Column07 
               ColumnWidth     =   1035.213
            EndProperty
            BeginProperty Column08 
               Alignment       =   2
               Locked          =   -1  'True
               ColumnWidth     =   494.929
            EndProperty
         EndProperty
      End
   End
End
Attribute VB_Name = "frmEnhanceCanvass"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'IT Group Inc. 2005.09.23

Option Explicit

'Object variables






'Recordset variables
Private WithEvents rsHeader As ADODB.Recordset
Attribute rsHeader.VB_VarHelpID = -1
Private rsDetail As ADODB.Recordset

'ADO Connection variables

Private connHeader As ADODB.Connection
Private connDetail As ADODB.Connection

'Form mode enumeration
Enum eCanvassMode
    Normal
    AddNewEdit
    Find
End Enum
Public Mode As eCanvassMode

'Other declarations
Public dtgName As String
Public sBit As String
Private vBM As Variant 'Recordset bookmark variable

Private lSystemGenerated As Boolean
Public strNo As String

'Security Acess Level variables
Public lACNew As Boolean
Public lACEdit As Boolean
Public lACDelete As Boolean
Public lACPost As Boolean
Public lACCancel As Boolean
Public lACPrint As Boolean

Private Sub cboCanvass_Click()
    rsDetail!cSupType = cboCanvass
End Sub

Private Sub cboCanvass_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        If dtgCanvass.Col = 0 Then
            rsDetail!cSupType = cboCanvass
            cboCanvass.Visible = False
            dtgCanvass.Col = 1
            dtgCanvass.SetFocus
        End If
    ElseIf KeyCode = vbKeyEscape Then
        cboCanvass.Visible = False
    End If
End Sub

Private Sub cboCanvass_LostFocus()
    cboCanvass.Visible = False
End Sub

Private Sub cboTerm_Click()
    rsDetail!cTerm = cboTerm
End Sub

Private Sub cboTerm_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        If dtgCanvass.Col = 3 Then
            rsDetail!cTerm = cboTerm
            cboTerm.Visible = False
            dtgCanvass.Col = 4
            dtgCanvass.SetFocus
        End If
    ElseIf KeyCode = vbKeyEscape Then
        cboTerm.Visible = False
    End If
End Sub

Private Sub cboTerm_LostFocus()
    cboTerm.Visible = False
End Sub

Private Sub cboType_Click()
    txtType = Trim(cboType)
    If Mode <> AddNewEdit Then Exit Sub
    ClearCanvassDetails
    ClearDataGrid
End Sub

Private Sub cboType_KeyPress(KeyAscii As Integer)
    SendKeysTab KeyAscii
End Sub

Private Sub chkNewSupplier_Click()
    If Mode <> AddNewEdit Then Exit Sub
    If chkNewSupplier.Value = Checked Then
        txtNewSupplier.Locked = False
        txtNewSupplier.SetFocus
    Else
        txtNewSupplier.Locked = True
        txtNewSupplier = Empty
    End If
End Sub

Private Sub chkSupplier_Click()
    If Mode <> AddNewEdit Then Exit Sub
    If chkSupplier.Value = Checked Then
        txtSupplier.Locked = False
        txtSupplier.SetFocus
    Else
        txtSupplier.Locked = True
        txtSupplier = Empty
    End If
End Sub

Private Sub cmdPickItemNo_Click()
    If Trim(cboType) = "" Then
        MsgBox "Please specify canvass type first.", vbExclamation, "ComUnion"
        cboType.SetFocus
        Exit Sub
    ElseIf Trim(txtPRNo) = "" Then
        MsgBox "Please specify reference PR No. first.", vbExclamation, "ComUnion"
        txtPRNo.SetFocus
        Exit Sub
    End If
    RepName = Trim(cboType)
    cString = Trim(txtPRNo)
    If lPickListActive Then Exit Sub
    frmITGPickList.mType = PRItemForCanvass
    frmITGPickList.Show vbModal
    txtItemNo = frmITGPickList.mCode
    txtDesc = frmITGPickList.mName
    If GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'ITM_MAN_BARCODE'") = True Then
        rsHeader!cBarcodeID = frmITGPickList.mName
    End If
    If Trim(txtDesc) <> "" Then
        txtQty = CDbl(frmITGPickList.mQty)
        rsHeader!nRefIdentity = frmITGPickList.mRefNo
        ItemLastWRRDetails txtItemNo
        SendKeys "{Tab}"
    End If
End Sub

Private Sub cmdPickPRNo_Click()
    If Trim(cboType) = "" Then
        MsgBox "Please specify canvass type first.", vbExclamation, "ComUnion"
        cboType.SetFocus
        Exit Sub
    End If
    RepName = Trim(cboType)
    If lPickListActive Then Exit Sub
    frmITGPickList.mType = PRForCanvass
    frmITGPickList.Show vbModal
    txtPRNo = frmITGPickList.mCode
    If Trim(txtPRNo) <> "" Then SendKeys "{Tab}"
End Sub

Private Sub dtgCanvass_AfterColUpdate(ByVal ColIndex As Integer)
    
    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 1
            If Trim(dtgCanvass.Columns(0).Text) = "Existing" Then
                If GetValueFrTable("cCode", "CLIENT_SUPPLIER", "cCode = '" & rsDetail!cCode & "'") <> "" Then
                    rsDetail!cName = GetValueFrTable("cName", "CLIENT_SUPPLIER", "cCode = '" & rsDetail!cCode & "'")
                    rsDetail!cTerm = GetValueFrTable("cTerm", "CLIENT_SUPPLIER", "cCode = '" & rsDetail!cCode & "'")
                    dtgCanvass.Col = 3
                    dtgCanvass.Columns(3).Value = rsDetail!cTerm
                End If
            End If
        Case 4
            rsDetail!nSavings = ComputeSavings(rsDetail!cTerm, rsDetail!nPrice)
    End Select
    
End Sub

Private Sub dtgCanvass_ButtonClick(ByVal ColIndex As Integer)
    If Mode <> AddNewEdit Then
        Select Case ColIndex
            Case 0, 3
                Exit Sub
        End Select
    End If
    'If Mode <> AddNewEdit Then Exit Sub
    
    Select Case ColIndex
        Case 0
            Call MoveCombo(cboCanvass, dtgCanvass, dtgCanvass.Columns(0))
            ComboLoadValue cboCanvass, Trim(dtgCanvass.Columns(0).Text)
        Case 1
            If Mode = AddNewEdit Then
                If Trim(dtgCanvass.Columns(0).Text) <> "Existing" Then Exit Sub
                If lPickListActive Then Exit Sub
                sFilterString = Trim(dtgCanvass.Columns(1).Text)
                frmITGPicker.zType = QSupplier
                frmITGPicker.Show vbModal
                rsDetail!cCode = Trim(frmITGPicker.zCode) & ""
                If (Trim(frmITGPicker.zName) & "") <> "" Then
                    rsDetail!cName = GetValueFrTable("cName", "CLIENT_SUPPLIER", "cCode = '" & rsDetail!cCode & "'")
                    rsDetail!cTerm = GetValueFrTable("cTerm", "CLIENT_SUPPLIER", "cCode = '" & rsDetail!cCode & "'")
                    dtgCanvass.Col = 3
                    dtgCanvass.Columns(3).Value = rsDetail!cTerm
                End If
            ElseIf Mode = Normal And Trim(dtgCanvass.Columns(0)) = "New" Then
                With frmMaintCustomerSupplier
                    If .Mode = 1 Then
                        MsgBox "Sytem detected that 'Supplier Module' is in Add/Edit mode." & _
                                vbCr & "Please save/undo the current transaction.", vbCritical + vbOKOnly, "Comunion"
                        .SetFocus
                        Exit Sub
                    Else
                        .Show
                        .ZOrder
                        .sTmpSCode = rsDetail!cCode
                        .TBNew
                    End If
                End With
            End If
        Case 3
            Call LoadComboValues(cboTerm, "cParamName", "PARAMETER_USER", "WHERE cType = 'TERMS' AND cCompanyID = '" & Trim(COID) & "'", "nOrder")
            Call MoveCombo(cboTerm, dtgCanvass, dtgCanvass.Columns(3))
            ComboLoadValue cboTerm, Trim(dtgCanvass.Columns(3).Text)
    End Select

End Sub

'Set the datagrid as active control
Private Sub dtgCanvass_Click()
    If Mode = AddNewEdit Then dtgName = dtgCanvass.Name
End Sub

Private Sub dtgCanvass_Error(ByVal DataError As Integer, Response As Integer)
    Response = 0
End Sub

Private Sub dtgCanvass_GotFocus()
    dtgName = dtgCanvass.Name
End Sub

Private Sub dtgCanvass_KeyDown(KeyCode As Integer, Shift As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If (Shift = vbCtrlMask And KeyCode = 45) Then
        TBNewLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 46) Then
        TBDeleteLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 83) Then
        TBSave
    End If
End Sub

Private Sub dtgCanvass_KeyPress(KeyAscii As Integer)
    
    If Mode <> AddNewEdit Then Exit Sub
    If rsDetail.RecordCount = 0 Then Exit Sub
    
    If KeyAscii = 39 Then KeyAscii = 0 'Apostrophe {'}
    
    If KeyAscii = 13 Then
        Select Case dtgCanvass.Col
            Case 0
                If Not cboCanvass.Visible Then dtgCanvass_ButtonClick (0)
            Case 1
                If GetValueFrTable("cCode", "CLIENT_SUPPLIER", "cCode = '" & rsDetail!cCode & "'") = "" Then
                    If Trim(dtgCanvass.Columns(0).Text) = "Existing" Then dtgCanvass_ButtonClick (1)                      'use button click
                End If
            Case 3
                If Not cboTerm.Visible Then dtgCanvass_ButtonClick (3)
            Case 7
                TBNewLine
                dtgCanvass.LeftCol = 0
            Case Else
                SendKeys "{Tab}"
        End Select
    Else: KeyAscii = Asc(UCase(Chr(KeyAscii)))       'All Upper Case String
    End If

End Sub

'Right click menu popup
Private Sub dtgCanvass_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Mode <> AddNewEdit Then Exit Sub
    If Button = 2 Then
        dtgName = dtgCanvass.Name
        PopupMenu ITGLedgerMain.mnuDetail
    End If
End Sub

Private Sub dtgCanvass_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
On Error Resume Next
    If Mode <> AddNewEdit Then Exit Sub
    
    If Trim(dtgCanvass.Columns(0).Text) = "New" Then
        dtgCanvass.Columns(2).Locked = False
    Else: dtgCanvass.Columns(2).Locked = True
    End If
End Sub

Private Sub dtgList_HeadClick(ByVal ColIndex As Integer)
    SortGrid dtgList, ColIndex, rsHeader
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Dim iKey As Integer
    iKey = ToolbarIndex(KeyCode, Shift)
    If iKey <> 0 Then
        If ITGLedgerMain.tbrMain.Buttons(iKey).Enabled = True Then
            ToolbarFunction iKey
        End If
    End If
End Sub

'Set Your Object
Private Sub Form_Load()

    Set FrmName = Me
    FormSetup

    'MUST BE REPLACED BY PROPER ACCESS LEVEL
    'This is same as Purchase Request
    AcessBit Me, GetValueFrTable("AccessLevel", "SEC_ACCESSLEVEL", "RoleID = '" & SecUserRole & "' AND [Module] = 'AP01'")
    
    Set rsHeader = New ADODB.Recordset
    Set rsDetail = New ADODB.Recordset
    

    FormLocking True
    FormSearch True
    SearchObj True
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
    BitVisible ITGLedgerMain.tbrMain, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True

    Mode = Find
    txtTranNo.Locked = False
   
End Sub

'Activate your Toolbar Mode
Private Sub Form_Activate()
    TBBitReload
End Sub

'Release your Object
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
    If Mode = AddNewEdit Then
        MsgBox "Unable to close. You are in Add/New/Edit mode." & vbCr & _
            " Must Save or Undo", vbCritical, Me.Caption
        Cancel = True
        Exit Sub
    End If
    
    CloseMenuTab ITGLedgerMain

    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , , , , , , , True
    BitVisible ITGLedgerMain.tbrMain
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = False

    
    
    
    
    Set rsHeader = Nothing
    Set rsDetail = Nothing
    Set connHeader = Nothing
    Set connDetail = Nothing
    
    Set frmEnhanceCanvass = Nothing

    lCloseWindow = True
    
'    'oForm(Me.Tag).Mode = 1
'    'oForm(Me.Tag).Tag = Me.Tag
End Sub

'Add new record to the recordset
Public Sub TBNew()

    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    txtTranNo.BackColor = &HE0FFFF
    Mode = AddNewEdit

    If rsHeader.State <> adStateOpen Then
        OpenNewConnection connHeader
        OpenNewConnection connDetail
        OpenRecordsetWithCN rsDetail, "*", "CANVASS_T", connDetail, "WHERE 1 = 0"
        OpenRecordsetWithCN rsHeader, "*", "CANVASS", connHeader, "WHERE 1 = 0"
        SetDataSource
        SetDataField
    Else: vBM = rsHeader.Bookmark
    End If

    rsHeader.AddNew
    rsHeader!cCompanyID = COID
    rsHeader!dDate = Date
    
    rsHeader!cType = "Trade"
    
    Set FrmName = Me
    FormLocking False
    ClrRequired &HC0&
    SSTab1.ActiveTab = 0
    txtPRNo.Locked = True
    txtItemNo.Locked = True
    txtNewSupplier.Locked = True
    txtSupplier.Locked = True
    chkNewSupplier.Value = Unchecked
    chkSupplier.Value = Unchecked
    txtTranNo.SetFocus
    Frame2.Enabled = True
    Frame3.Enabled = True
            
    'system generated number
    lSystemGenerated = GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'AUTO_NUMBER_CNVS' ")
    If lSystemGenerated Then rsHeader!cTranNo = GetAutoCtrlNo(rsHeader, "AUTO_NUMBER_CNVS", "CANVASS", "cTranNo")
    
End Sub

'Undo all changes to the recordset
Public Sub TBUndoAll()
On Error GoTo ErrorHandler

    Mode = Normal
    Frame2.Enabled = False
    Frame3.Enabled = False
    
    If rsHeader.Status = adRecNew Then TBUndoCurrent
    
    rsHeader.CancelBatch adAffectAll
    rsDetail.CancelBatch adAffectAll
    
    UnbindControls
    
    If rsHeader.RecordCount <> 0 Then rsHeader.Bookmark = vBM
    
    Set FrmName = Me
    FormLocking True
    
    If rsHeader.RecordCount <> 0 Then
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , , , , True, True, , True
    Else
        RSZero
        Mode = Find
    End If

    sbRS.Panels(2) = ""
    
    SetDataSource
    SetDataField

ErrorHandler:
    cboCanvass.Visible = False
    cboTerm.Visible = False

    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217842 Then 'Operation was cancelled. (Error returned by ITGDateBox)
        TBUndoAll
    End If

End Sub

'Undo changes on the current record
Public Sub TBUndoCurrent()
On Error GoTo ErrorHandler

    GetChild
    If rsHeader.Status = adRecNew Then
        rsDetail.CancelBatch adAffectAll
        rsHeader.CancelUpdate
        
    Else
        rsHeader.CancelBatch adAffectCurrent
        rsDetail.CancelBatch adAffectAll
    End If
    
    If rsHeader.RecordCount = 0 Then RSZero
    
ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217842 Then 'Operation was cancelled. (Error returned by ITGDateBox)
        TBUndoCurrent
    End If

End Sub

'Save all changes
Public Sub TBSave()
Dim OKUpdate As Boolean
On Error GoTo ErrHandler

    'Audit Trail
    lBoolean = False
    If rsHeader.Status = adRecNew Then lBoolean = True
    
    If Not MandatoryOK Then Exit Sub
    
    'System generated number
    If rsHeader.Status = adRecNew Then
        If lSystemGenerated Then
            If ChkCtrlNo(rsHeader, "AUTO_NUMBER_CNVS", "CANVASS", "cTranNo", rsHeader!cTranNo) <> rsHeader!cTranNo Then
                GetChild
                
                rsHeader!cTranNo = strNo
                
                If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
                Do Until rsDetail.EOF
                    rsDetail!cTranNo = strNo
                    rsDetail.MoveNext
                Loop
                
                GetChild
            End If
        End If
    End If
        
    OKUpdate = False
    cn.BeginTrans
    connHeader.BeginTrans
    connDetail.BeginTrans
        
    rsHeader.UpdateBatch adAffectAll
    rsDetail.UpdateBatch adAffectAll
    
    cn.CommitTrans
    connHeader.CommitTrans
    connDetail.CommitTrans
    OKUpdate = True
    
    Set FrmName = Me
    FormLocking True
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , , , , True, True, , True
    Mode = Normal
        
    'Audit trail
    UpdateLogFile "Canvass", Trim(txtTranNo), IIf(lBoolean, "Inserted", "Updated")
    'update system generated number
    If lBoolean Then
        If lSystemGenerated And strNo = rsHeader!cTranNo Then UpdateControlNo strNo, rsHeader!cTranNo, "AUTO_NUMBER_CNVS"
    End If

    MsgBox "Record/s successfully saved.", vbInformation, "ComUnion"
    sbRS.Panels(2) = ""
    
    
    Frame2.Enabled = False
    Frame3.Enabled = False

ErrHandler:
    cboCanvass.Visible = False
    cboTerm.Visible = False
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217864 Then
        OKUpdate = True
        cn.RollbackTrans
        connHeader.RollbackTrans
        connDetail.RollbackTrans
        MsgBox "Record cannot be updated. Some values may have been changed by other user/s since last read." & vbCr & _
                "Records will be automatically refreshed. All changes made to the record will be gone upon refresh.", vbInformation, "ComUnion"
        vBookMark = rsHeader.Bookmark
        UnbindControls
        rsHeader.Requery
        rsDetail.Requery
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , , , , True, True, , True
        Mode = Normal
        If rsHeader.RecordCount <> 0 Then
            Set FrmName = Me
            FormLocking True
            SetDataField
            SetDataSource
            rsHeader.Bookmark = vBookMark
        Else: RSZero
        End If
    End If
    If Not OKUpdate Then
        MsgBox "Transaction update failed.", vbInformation, "ComUnion"
        cn.RollbackTrans
        connHeader.RollbackTrans
        connDetail.RollbackTrans
        ErrorLog err.Number, err.Description, Me.Name 'Error log
    End If
    
End Sub

'Sets the form & recorset to add/edit mode
Public Sub TBEdit()

    If rsHeader!lCancelled Then
        MsgBox "Transaction was already cancelled. Edit is not allowed.", vbExclamation, "ComUnion"
        Exit Sub
    End If
    
    GetChild
    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    Do Until rsDetail.EOF
        If rsDetail!lApproved Then
            MsgBox "Transaction have already approved supplier. Edit is not allowed.", vbExclamation, "ComUnion"
            Exit Sub
        End If
        rsDetail.MoveNext
    Loop
        
    Mode = AddNewEdit
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    Set FrmName = Me
    FormLocking False
    ClrRequired &HC0&
    txtTranNo.Locked = True
    txtPRNo.Locked = True
    txtItemNo.Locked = True
    Frame2.Enabled = True
    Frame3.Enabled = True
    SSTab1.ActiveTab = 0
    dtbDate.SetFocus
    vBM = rsHeader.Bookmark
End Sub

'Delete record
Public Sub TBDelete()
On Error GoTo ErrorHandler

    sID = Trim(txtTranNo)
    
    If rsHeader.RecordCount = 0 Then Exit Sub
    
    If rsHeader!lCancelled Then
        MsgBox "Transaction was already cancelled. Deletion is not allowed.", vbExclamation, "ComUnion"
        Exit Sub
    End If
    
    GetChild
    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    Do Until rsDetail.EOF
        If rsDetail!lApproved Then
            MsgBox "Transaction have already approved supplier. Deletion is not allowed.", vbExclamation, "ComUnion"
            Exit Sub
        End If
        rsDetail.MoveNext
    Loop
    
    If MsgBox("Are you sure you want to delete this record?", vbQuestion + vbYesNo, "ComUnion") = vbNo Then Exit Sub

    GetChild
    If rsDetail.RecordCount <> 0 Then
        rsDetail.MoveFirst
        Do Until rsDetail.RecordCount = 0
            rsDetail.Delete adAffectCurrent
            If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
        Loop
    End If
    
    'Audit trail
    UpdateLogFile "Canvass", Trim(txtTranNo), "Deleted"

    rsHeader.Delete adAffectCurrent
    
    rsDetail.UpdateBatch adAffectAll
    rsHeader.UpdateBatch adAffectAll
    
    TBPrevRec


    Mode = Normal

    If rsHeader.RecordCount = 0 Then
        RSZero
    End If

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217864 Then
        cn.Execute "DELETE CANVASS_T WHERE cTranNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        cn.Execute "DELETE CANVASS WHERE cTranNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        Resume Next
    
    'mon
    ElseIf err.Number = -2147217887 Then
        cn.Execute "DELETE CANVASS_T WHERE cTranNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        cn.Execute "DELETE CANVASS WHERE cTranNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        Resume Next
        Else
        Resume Next
        
    End If

End Sub

'Search using the frmITGSearch
Public Sub TBFind()
    Mode = Normal
    txtTranNo.Locked = True
    frmITGSearch.Show 'vbModal
End Sub

'Search using the recordset primary key
Public Sub TBFindPrimary()
Dim sTemp As String
If Mode = Find Then
    FormWaitShow App.Path & "\Transmit.avi", "Loading data . . ."
        
    OpenNewConnection connHeader
    OpenNewConnection connDetail
    
    Set rsHeader = Nothing
    Set rsDetail = Nothing
    Set rsHeader = New ADODB.Recordset
    Set rsDetail = New ADODB.Recordset

    sTemp = Trim$(GetSearchString)
    If sTemp = "ERROR" Then
        MsgBox "Only Allows A - Z, 0 - 9, '.', ',' and %(wildcard)", vbExclamation, ""
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
        txtTranNo.Locked = False
        txtTranNo.SetFocus
        Exit Sub
    End If
    
    OpenRecordsetWithCN rsHeader, "*", "CANVASS", connHeader, IIf(sTemp = "", "", " WHERE " & sTemp)
    'OpenRecordsetWithCN rsDetail, "*", "CANVASS_T", connDetail
               
    OpenRecordsetWithCN rsDetail, "*", "CANVASS_T", connDetail, IIf(sTemp = "", "", " WHERE cTranNo IN (SELECT cTranNo FROM CANVASS WHERE " & sTemp & ")")
      
    Set FrmName = Me
    FormLocking True

    If rsHeader.RecordCount = 0 Then
        FormWaitHide
        MsgBox "No matching record/s found.", vbInformation, "ComUnion Search"
        RSZero
        FormSearch True
        SearchObj True
        Mode = Find
        Exit Sub
    End If
    SetDataSource
    SetDataField
    txtTranNo.BackColor = &HE0FFFF
    Mode = Normal
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , , , , True, True, , True

    FormWaitHide
Else
    RSZero
    FormSearch True
    SearchObj True
    Mode = Find
   
End If

End Sub

'Reload menu buttons (do not delete this sub)
Public Sub TBBitReload()
    BitVisible ITGLedgerMain.tbrMain, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True
    BitReload ITGLedgerMain, Me, ITGLedgerMain.tbrMain, sBit
    Set FrmName = Me
    dtgName = dtgCanvass.Name
End Sub

'Close active window
Public Sub TBCloseWindow()
    Unload Me
End Sub

'Move first
Public Sub TBFirstRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveFirst rsHeader

End Sub

'Move previuos
Public Sub TBPrevRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MovePrevious rsHeader

End Sub

'Move next
Public Sub TBNextRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveNext rsHeader

End Sub

'Move last
Public Sub TBLastRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveLast rsHeader

End Sub

'Add new line to the detail recordset
Public Sub TBNewLine()
    
    If rsHeader!cTranNo = "" Then Exit Sub
    
    If dtgName = "dtgCanvass" Then
        rsDetail.AddNew
        rsDetail!cCompanyID = COID
        rsDetail!cTranNo = Trim(rsHeader!cTranNo)
        rsDetail!lApproved = False
        dtgCanvass.Col = 0
        dtgCanvass.Columns(0).Value = ""
        GetChild
        If rsDetail.RecordCount <> 0 Then rsDetail.MoveLast
        dtgCanvass.SetFocus
    End If
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True

End Sub

'Delete line in the detail recordset
Public Sub TBDeleteLine()
On Error GoTo ErrorHandler

    If dtgName = dtgCanvass.Name Then
        If rsDetail.RecordCount = 0 Then Exit Sub
        vBookMark = dtgCanvass.Bookmark
        GetChild
        dtgCanvass.Bookmark = vBookMark
        rsDetail.Delete adAffectCurrent
    End If
    GetChild

    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Undo All
Public Sub TBUndoLineAll()
On Error GoTo ErrorHandler

    MsgBox "Unavailable on " & Me.Name

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Undo current line
Public Sub TBUndoLineCurrent()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Post current record
Public Sub TBPostRecord()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Cancel current record
Public Sub TBCancelRecord()
On Error GoTo ErrorHandler
    
    If rsHeader.RecordCount = 0 Then Exit Sub

    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled.", vbExclamation, "ComUnion"
        Exit Sub
    End If
    
    GetChild
    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    Do Until rsDetail.EOF
        If rsDetail!lApproved Then
            MsgBox "Transaction have already approved supplier. Cancellation is not allowed.", vbExclamation, "ComUnion"
            Exit Sub
        End If
        rsDetail.MoveNext
    Loop
    
    If MsgBox("Are you sure you want to cancel this record?", vbQuestion + vbYesNo, "ComUnion") = vbNo Then Exit Sub
    
    'Audit trail
    UpdateLogFile "Canvass", Trim(txtTranNo), "Cancelled"

    cn.Execute ("UPDATE CANVASS SET lCancelled = 1 WHERE cTranNo = '" & Trim(txtTranNo) & "' AND cCompanyID = '" & COID & "'")
    
    sbRS.Panels(5) = "CANCELLED"
    Mode = Normal
    
    rsHeader!lCancelled = True
    rsHeader.UpdateBatch adAffectAll

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Print
Public Sub TBPrintRecord()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Sets the data source of the controls
Sub SetDataSource()
    Set FrmName = Me
    BindControls rsHeader
    Set dtgList.DataSource = rsHeader
    Set dtgCanvass.DataSource = rsDetail
    
End Sub

'Sets the data field for every bounded controls
Sub SetDataField()
    With rsHeader
        txtTranNo.DataField = !cTranNo
        dtbDate.DataField = !dDate
        txtType.DataField = !cType
        txtPRNo.DataField = !cPRNo
        txtItemNo.DataField = !cItemNo
        txtDesc.DataField = !cDesc
        txtQty.DataField = !nQty
        txtBalance.DataField = !nBalance
        txtLastPrice.DataField = !nLastPrice
        txtTerm.DataField = !cTerm
        txtCode.DataField = !cCode
        txtBankRate.DataField = !nBankRate
        txtLowestCODPrice.DataField = !nLowestCODPrice
        txtNewSupplier.DataField = !nNewSupplier
        txtSupplier.DataField = !nSupplier
    End With
End Sub

Private Sub rsHeader_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
On Error GoTo ErrorHandler

    If Not (rsHeader.EOF) Or Not (rsHeader.BOF) Then
        'Status bar setup
        sbRS.Panels(1) = "Record: " & IIf((rsHeader.AbsolutePosition = -2), "0", rsHeader.AbsolutePosition) & "/" & rsHeader.RecordCount

        If rsHeader.Status <> adRecNew Then
            txtTranNo.Locked = True
        Else
            txtTranNo.Locked = False
        End If

        If Mode = AddNewEdit Then
            Select Case rsHeader.Status
                Case adRecNew
                    sbRS.Panels(2) = "New"
                Case adRecModified
                    sbRS.Panels(2) = "Modified"
                Case Else
                    sbRS.Panels(2) = ""
            End Select
        Else: sbRS.Panels(2) = ""
        End If
        
        GetChild
        
        If rsHeader!lCancelled = True Then
            sbRS.Panels(5) = "CANCELLED"
        Else: sbRS.Panels(5) = ""
        End If
    
    Else
        sbRS.Panels(1) = "Record: 0/0"
        sbRS.Panels(2) = ""
        txtTranNo.Locked = False
    End If

    If Mode = AddNewEdit Then
        dtgCanvass.Refresh
    End If

ErrorHandler:
    'Err.Number -2147217885
    'Description - Row handle referred to a deleted row or a row marked for deletion.
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

Private Sub Timer1_Timer()
    If Mode = AddNewEdit Then
        SSTab1.TabEnabled(1) = False
    Else: SSTab1.TabEnabled(1) = True
    End If
End Sub

Private Sub txtBankRate_Change()
    If Mode <> AddNewEdit Then Exit Sub
    
End Sub

Private Sub txtCode_Change()
    txtName = ""
    txtName = GetValueFrTable("cName", "CLIENT_SUPPLIER", "cCode = '" & Trim(txtCode) & "'")
End Sub

Private Sub txtLowestCODPrice_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If rsDetail.RecordCount < 1 Then TBNewLine
End Sub

Private Sub txtNewSupplier_Change()
    If Mode <> AddNewEdit Then
        If CDbl(txtNewSupplier) > 0 Then
            chkNewSupplier.Value = Checked
        Else: chkNewSupplier.Value = Unchecked
        End If
    End If
End Sub

Private Sub txtSupplier_Change()
    If Mode <> AddNewEdit Then
        If CDbl(txtSupplier) > 0 Then
            chkSupplier.Value = Checked
        Else: chkSupplier.Value = Unchecked
        End If
    End If
End Sub

Private Sub txtTranNo_LostFocus()
    'Does Code Already Exist
    If Mode = AddNewEdit Then
        If Trim(txtTranNo) = "" Then
            MsgBox "Empty primary input.", vbInformation, "ComUnion"
            If FrmName.Name <> Me.Name Then PreviousTab frmComUnionMenuTab
            txtTranNo.SetFocus
        Else
            If rsHeader.Status <> adRecNew Then Exit Sub
            txtTranNo = Trim(txtTranNo)
            If IDExisting(rsHeader, "cTranNo", "CANVASS", Trim(rsHeader!cTranNo)) Then
                MsgBox "Canvass No. already exist.", vbInformation, "ComUnion"
                If FrmName.Name <> Me.Name Then PreviousTab frmComUnionMenuTab
                txtTranNo.SetFocus
            End If
        End If
    End If
End Sub

'Check if all mandatory fields are complete
Function MandatoryOK() As Boolean

    MandatoryOK = True

    If Trim(txtTranNo) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Canvass Number' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        txtTranNo.SetFocus
        Exit Function
    End If
    
    If rsHeader.Status = adRecNew Then
        If IDExisting(rsHeader, "cTranNo", "CANVASS", Trim(rsHeader!cTranNo)) Then
            MandatoryOK = False
            MsgBox "Canvass No. already exist.", vbInformation, "ComUnion"
            txtTranNo.SetFocus
            Exit Function
        End If
    End If

    ReComputeSavings

    'Required fields
    If Trim(dtbDate.Text) = "__/__/____" Then
        MandatoryOK = False
        MsgBox "Field 'Transaction Date' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        dtbDate.SetFocus
        Exit Function
    ElseIf Trim(txtType) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Canvass Type' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        cboType.SetFocus
        Exit Function
    ElseIf Trim(txtPRNo) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Reference PR No.' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        txtPRNo.SetFocus
        Exit Function
    ElseIf Trim(txtItemNo) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Product' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        txtItemNo.SetFocus
        Exit Function
    End If
    
    GetChild
    
    'Transaction without details
    If rsDetail.RecordCount = 0 Then
        MandatoryOK = False
        MsgBox "Cannot save transaction without details.", vbInformation, "ComUnion"
        dtgCanvass.SetFocus
        Exit Function
    End If
    
    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    Do Until rsDetail.EOF
        If rsDetail.Status = (adRecNew) Or rsDetail.Status = (adRecModified) Then
            If IsNull(rsDetail!cSupType) Then
                rsDetail.Delete
            ElseIf Trim(rsDetail!cSupType) = "" Then
                rsDetail.Delete
            ElseIf IsNull(rsDetail!cCode) Then
                rsDetail.Delete
            ElseIf Trim(rsDetail!cCode) = "" Then
                rsDetail.Delete
            Else: rsDetail.MoveNext
            End If
        Else: rsDetail.MoveNext
        End If
    Loop

    GetChild

    If rsDetail.RecordCount < 1 Then
        MsgBox "Cannot save transaction without details.", vbExclamation, "ComUnion"
        MandatoryOK = False
        Exit Function
    End If

    If Not SupplierCountOK Then
        MandatoryOK = False
        Exit Function
    End If

End Function

'Filter detail recordset to header's primary
Private Sub GetChild()
    rsDetail.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
End Sub

Private Function GetSearchString() As String
On Error GoTo ErrorHandler
Dim sWhere As String

    GetSearchString = True

    If Trim$(txtTranNo.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cTranNo LIKE '" & Trim$(txtTranNo.Text) & "%'"
    End If

    If Trim$(dtbDate.Text) <> "__/__/____" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " dDate = '" & Trim$(dtbDate.Text) & "'"
    End If
    
    If Trim$(txtType.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cType LIKE '" & Trim$(txtType.Text) & "%'"
    End If
    
    If Trim$(txtPRNo.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cPRNo LIKE '" & Trim$(txtPRNo.Text) & "%'"
    End If
    
    If Trim$(txtItemNo.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cItemNo LIKE '" & Trim$(txtItemNo.Text) & "%'"
    End If
    
    GetSearchString = Trim$(sWhere)

    Exit Function
ErrorHandler:
    GetSearchString = "ERROR"
End Function


'Sets the form if record number is zero
Private Sub RSZero()
    sbRS.Panels(1) = "Record: 0/0"
    sbRS.Panels(2) = ""
    sbRS.Panels(4) = ""
    sbRS.Panels(5) = ""
    
    Set dtgCanvass.DataSource = Nothing
    dtgCanvass.Refresh
    
    Set FrmName = Me
    UnbindControls
    TextClearing
    FormLocking True
    
    If rsHeader.State = adStateOpen Then rsHeader.Close
    If rsDetail.State = adStateOpen Then rsDetail.Close
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
    
    txtTranNo.Locked = False
    txtTranNo.SetFocus
    
    Mode = Find
    
End Sub

Sub SearchObj(lEnable As Boolean)
    dtbDate.Enabled = lEnable
    cboType.Enabled = lEnable
End Sub

Private Sub ClearCanvassDetails()
    txtPRNo = Empty
    txtItemNo = Empty
    txtQty = Empty
    txtBalance = Empty
    txtLastPrice = Empty
    txtTerm = Empty
    txtCode = Empty
    txtBankRate = Empty
    txtLowestCODPrice = Empty
    txtNewSupplier = Empty
    txtSupplier = Empty
End Sub

'Clear Data Grid
Private Sub ClearDataGrid()
    GetChild
    If rsDetail.RecordCount <> 0 Then
        rsDetail.MoveFirst
        Do Until rsDetail.RecordCount = 0
            rsDetail.Delete adAffectCurrent
            If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
        Loop
    End If
    GetChild
End Sub

'Item last WRR details
Private Sub ItemLastWRRDetails(sItem As String)
    Dim sBCode As String
    
    Set rs = New Recordset

    sSQL = "SELECT TOP 1 A.cCompanyID, A.cWRRNo, B.dDate, A.cItemNo, A.cDesc, A.nPrice, C.cTerm, B.cCode, D.cName, a.cBarcodeID " & _
            "FROM WRR_T A " & _
            "LEFT OUTER JOIN WRR B ON A.cCompanyID = B.cCompanyID AND A.cWRRNo = B.cWRRNo " & _
            "LEFT OUTER JOIN PO C ON A.cCompanyID = C.cCompanyID AND A.cRefNo = C.cPONo " & _
            "LEFT OUTER JOIN CLIENT_SUPPLIER D ON B.cCompanyID = D.cCompanyID AND B.cCode = D.cCode " & _
            "WHERE B.lCancelled = 0 AND B.cType = 'Purchase' AND A.cCompanyID = '" & COID & "' " & _
            "AND A.cItemNo = '" & sItem & "' " & _
            "ORDER BY B.dDate DESC"
            
    rs.Open sSQL, cn, adOpenForwardOnly, adLockReadOnly
    If GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'ITM_MAN_BARCODE'") = False Then
        If rs.RecordCount > 0 Then
            sBCode = rs!cBarcodeID
        End If
    End If
    If rs.RecordCount > 0 Then
        txtLastPrice = rs!nPrice
        txtTerm = rs!cTerm & ""
        txtCode = rs!cCode & ""
    Else
        txtLastPrice = Empty
        txtTerm = Empty
        txtCode = Empty
    End If
    
    Set rs = Nothing
    
    Dim rsBal As New ADODB.Recordset
    If GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'ITM_MAN_BARCODE'") = False Then
        If Trim(cboType) = "Trade" Then
            ProductBalanceCommand rsBal, sItem
        ElseIf Trim(cboType) = "Supply" Then
            sSQL = "SELECT *, ISNULL((nInitial - nOutgoing + nIncoming + nAdjustment), 0) AS nBalance " & _
                "FROM V_SuppliesBalanceInquiry_Module WHERE cSupplyNo = '" & sItem & "' AND cCompanyID = '" & COID & "'"
        End If
    Else
        If Trim(cboType) = "Trade" Then
            sSQL = "exec sp_ProductBalanceInquiry_ModuleWPartNo '" & sItem & "', '" & sBCode & "', '" & COID & "'"
        ElseIf Trim(cboType) = "Supply" Then
            sSQL = "SELECT *, ISNULL((nInitial - nOutgoing + nIncoming + nAdjustment), 0) AS nBalance " & _
                "FROM V_SuppliesBalanceInquiry_Module WHERE cSupplyNo = '" & sItem & "' AND cCompanyID = '" & COID & "'"
        End If
    End If
    
    If rsBal.State = adStateOpen Then rsBal.Close
    rsBal.Open sSQL, cn, adOpenStatic, adLockOptimistic
        
    If rsBal.RecordCount > 0 Then
        If Trim(cboType) = "Trade" Then
            txtBalance = rsBal!nBalance - rsBal!nReserved
        ElseIf Trim(cboType) = "Supply" Then
            txtBalance = rsBal!nBalance
        End If
    Else: txtBalance = Empty
    End If
    rsBal.Close
    Set rsBal = Nothing

End Sub

Private Sub txtType_Change()
    If Trim(txtType) <> "" Or txtType <> vbNullString Then
        cboType = Trim(txtType)
    Else: cboType.ListIndex = -1
    End If
End Sub

'Computes total amount per detail line
Private Function ComputeSavings(sITerm As String, nIPrice As Double) As Double
On Error GoTo TheSource
Dim nTerms As Double
Dim nSavings As Double

    nTerms = GetValueFrTable("cValue", "PARAMETER_USER", "cParamName = '" & sITerm & "'")
    nSavings = CDbl(txtLowestCODPrice) + (((IIf(IsNull(nTerms), 0, nTerms)) / 360) * ((CDbl(txtBankRate)) / 100) * CDbl(txtLowestCODPrice)) - nIPrice

    ComputeSavings = nSavings
    
TheSource:
    If err.Number <> 0 Then ComputeSavings = 0
End Function

'ReCompute Savings
Private Sub ReComputeSavings()
    GetChild
    
    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    Do Until rsDetail.EOF
        rsDetail!nSavings = ComputeSavings(rsDetail!cTerm, rsDetail!nPrice)
        rsDetail.MoveNext
    Loop
    
    GetChild
End Sub

Function SupplierCountOK() As Boolean
Dim nNew As Long
Dim nOld As Long

    SupplierCountOK = True

    If CDbl(txtNewSupplier) > 0 Then
        GetChild
        
        If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
        Do Until rsDetail.EOF
            If rsDetail!cSupType = "New" Then nNew = nNew + 1
            rsDetail.MoveNext
        Loop
        
        GetChild
        
        If nNew < CDbl(txtNewSupplier) Then
            MsgBox "Must have at least " & Trim(txtNewSupplier) & " new Supplier/s!", vbExclamation, "ComUnion"
            SupplierCountOK = False
            Exit Function
        End If
        
    End If

    If CDbl(txtSupplier) > 0 Then
        GetChild
        
'        If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
'        Do Until rsDetail.EOF
'            If rsDetail!cSupType = "Existing" Then nOld = nOld + 1
'            rsDetail.MoveNext
'        Loop
        
'        GetChild
        
'        If nOld < CDbl(txtSupplier) Then
        If rsDetail.RecordCount < CDbl(txtSupplier) Then
            MsgBox "Must have at least " & Trim(txtSupplier) & " Supplier/s!", vbExclamation, "ComUnion"
            SupplierCountOK = False
            Exit Function
        End If
        
    End If

End Function

Public Sub ShowTran()

    If Mode = Find Then

        OpenNewConnection connHeader
        OpenNewConnection connDetail

        Set rsHeader = Nothing
        Set rsDetail = Nothing
        Set rsHeader = New ADODB.Recordset
        Set rsDetail = New ADODB.Recordset

        OpenRecordsetWithCN rsDetail, "*", "CANVASS_T", connDetail, "WHERE cTranNo = '" & Trim(txtTranNo) & "'", True
        OpenRecordsetWithCN rsHeader, "*", "CANVASS", connHeader, "WHERE cTranNo = '" & Trim(txtTranNo) & "'", True

        Set FrmName = Me
        FormLocking True

        If rsHeader.RecordCount = 0 Then
            FormWaitHide
            MsgBox "No matching record/s found.", vbInformation, "ComUnion Search"
            RSZero
            FormSearch True
            SearchObj True
            Mode = Find
            Exit Sub
        End If
            SetDataSource
            SetDataField
            txtTranNo.BackColor = &HE0FFFF
            Mode = Normal
            BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , , , True, , , , True, , , True
'            oBar.BitEnabled Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , , , , True, True, , True, True

    End If
End Sub
